package com.lj.ljminsu.merchant.GuanjiaController;

import com.lj.ljminsu.merchant.GuanjiaBean.PinjiaUtil;
import com.lj.ljminsu.merchant.GuanjiaBean.TjPinjia;
import com.lj.ljminsu.merchant.GuanjiaService.IoPinjService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Controller
@CrossOrigin
public class PInjiaController {
    @Resource
    private IoPinjService ioPinjService;
    @RequestMapping("PinjiaA")
    @ResponseBody
    public  List<TjPinjia> tjPiniaList(Integer oderId,Integer sta ){
        PinjiaUtil pinjiaUtil = new PinjiaUtil();
        List<TjPinjia> tjPinjias = ioPinjService.FindGList(pinjiaUtil);
        List<TjPinjia> tjPinjiasS=new ArrayList<>();
        if (sta==1){
            for(TjPinjia jPinjia:tjPinjias ){
                if(jPinjia.getsDesc().equals("1")&&!jPinjia.getKeDesc().equals("1")){
                    tjPinjiasS.add(jPinjia);
                }
            }
            return tjPinjiasS;
        }else if(sta==2) {
            for (TjPinjia jPinjia : tjPinjias) {
                if (jPinjia.getKeDesc().equals("1")){
                    tjPinjiasS.add(jPinjia);
                }
            }
            return tjPinjiasS;
        }else if (sta>2){
            for (TjPinjia jPinjia : tjPinjias) {
                if (jPinjia.getOderId() == sta) {
                    tjPinjiasS.add(jPinjia);
                }
                }
                return tjPinjiasS;
            }else {
            return tjPinjias;
        }
    }
}
